#ifndef AUDIOINPUTSAMP_H
#define AUDIOINPUTSAMP_H

#include <QWidget>
#include <QLineSeries>
#include <QAudioDeviceInfo>
#include <QAudioInput>
#include "MineDisplayDevice.h"

using namespace QtCharts;

QT_BEGIN_NAMESPACE
namespace Ui { class AudioInputSamp; }
QT_END_NAMESPACE

class AudioInputSamp : public QWidget
{
    Q_OBJECT

public:
    AudioInputSamp(QWidget *parent = nullptr);
    ~AudioInputSamp();

private slots:
    //自定义槽函数
    void onIODeviceUpdateBlockSize(qint64 blockSize) ;

private slots:
    //UI 设计自动关联槽
    void on_comboDevices_currentIndexChanged(int index);
    void on_actDeviceTest_clicked();
    void on_actStart_clicked();

    void on_actStop_clicked();

private:
    Ui::AudioInputSamp *ui;

    const  qint64  m_displayPointsCount = 4000;
    QLineSeries * m_lineSeries = nullptr; //曲线序列

    QList <QAudioDeviceInfo> m_DeviceList; //音频输入设备列表

    QAudioDeviceInfo m_currentDevice; //当前输入设备
    MineDisplayDevice * m_mineDisplayDevice; //用于显示的IODevice

    QAudioInput * m_AudioInput = nullptr; //音频输入设备

private:
    QString SampleTypeString (QAudioFormat::SampleType sampleType);
    QString ByteOrderString (QAudioFormat::Endian endian);

};
#endif // AUDIOINPUTSAMP_H
